package com.ldxiwxr.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ldxiwxr.system.entity.article.Article;
import com.ldxiwxr.system.mapper.ArticleMapper;
import com.ldxiwxr.system.service.IArticleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ArticleServiceImpl implements IArticleService {

    @Resource
    private ArticleMapper articleMapper;

    @Override
    public List<Article> getArticleList(int nums,String title) {
        return articleMapper.selectList(Wrappers.<Article>lambdaQuery().like(title != null,Article::getArticleTitle,title).last("limit " + nums));
    }

    @Override
    public Article getArticleContent(String articleId) {
        return articleMapper.selectById(articleId);
    }
}
